home *** CD-ROM | disk | FTP | other *** search
/ GFX Sensations 1 / Graphic Sensations - Volume 1.iso / tools / amiga / 3d_tools / irit40s.lha / Irit / irit / ctrl-brk.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-30  |  1.2 KB  |  37 lines

  1. /*****************************************************************************
  2. * Module to trap ctrl-brk/hardware error and handle them gracefully.         *
  3. *                                         *
  4. * Written by:  Gershon Elber                Ver 1.1, Mar. 1990   *
  5. *****************************************************************************/
  6.  
  7. #include <signal.h>
  8. #include <stdio.h>
  9. #include "program.h"
  10. #include "inptprsg.h"
  11. #include "ctrl-brk.h"
  12.  
  13. /*****************************************************************************
  14. * Routine TrapCtrlC gain control if Control C was typed (DOS level):         *
  15. *****************************************************************************/
  16. static void TrapCtrlC(int Type)
  17. {
  18.     printf("\n*** Break ***\n");
  19.     fflush(stdout);
  20.     SetUpCtrlBrk();
  21.  
  22.     FlushToEndOfExpr(FALSE);
  23.     longjmp(GlblLongJumpBuffer, 1);
  24. }
  25.  
  26. /*****************************************************************************
  27. * Routine SetUpCtrlBrk must be called once by main program:             *
  28. *****************************************************************************/
  29. void SetUpCtrlBrk(void)
  30. {
  31.     signal(SIGINT, TrapCtrlC);
  32. #if defined(__UNIX__) || defined(OS2GCC)
  33.     signal(SIGQUIT, TrapCtrlC);
  34.     signal(SIGKILL, IritExit0);
  35. #endif /* __UNIX__ || OS2GCC */
  36. }
  37.